<#include "/admin/common/head.html"/>
			<!-- /section:basics/sidebar -->
			<div class="main-content">
				<div class="main-content-inner">
					<!-- /section:basics/content.breadcrumbs -->
					<div class="page-content">
						<div class="page-header">
							<h1>
								首页
								<small>
									<i class="ace-icon fa fa-angle-double-right"></i>
									用户管理
								</small>
							</h1>
						</div><!-- /.page-header -->
						<div id="tabs">
						<ul>
                        	<li>
                            <a href="#tabs-1"  onClick="optQuery('common')"><i class="blue  fa fa-check-circle-o bigger-120"></i>普通用户</a>
                        	</li>

                        	<li>
                            <a href="#tabs-1"  onClick="optQuery('admin')"><i class="green ace-icon fa fa-check-circle-o bigger-120"></i>管理员</a>
                       		 </li>
                        </ul>
          

					<div id="tabs-1" class="col-xs-12" style="padding-left: 5px;">
						<span>姓名 :&nbsp;&nbsp;<input type="text" name="truename"></span>&nbsp;&nbsp;&nbsp;&nbsp;
						<span><button class="btn btn-xs btn-info" type="button" onclick="query()">查询</button></span>
                    	<@p.table id="user" url="/user/getPager"  multiselect=false height=250>
                    	<@p.column name="uid" title="uid" width=0 hidden=true/>
						<@p.column name="username" title="用户名" width=30/>
                    	<@p.column name="truename" title="真实姓名" width=30/>
                    	<@p.column name="email" title="邮箱" />
                    	<@p.column name="tel" title="联系电话" />
                    	<@p.column name="opt" title="操作"  buttons="displayButtons" width=100/>
                		</@p.table>
            		</div>
            		</div>
					</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->
		<#include "/admin/common/foot.html"/>
		<script type="text/javascript">
		var type="common";
		jQuery(function($) {
	    	$( "#tabs" ).tabs();
		});
		 function displayButtons(cellvalue, options, rowObject){
			 if(type=="common"){
		        return"<a class='green' title=\"设为管理员\" href='javascript:optGrant(\""+rowObject.uid+"\",\""+rowObject.username+"\",\""+rowObject.truename+"\")'><i class='ace-icon fa fa-users bigger-130'></i></a>&nbsp;&nbsp;"
			 }
			if(type=="admin"){
				 return"<a class='green' title=\"取消管理员\" href='javascript:optCancelGrant(\""+rowObject.uid+"\",\""+rowObject.username+"\",\""+rowObject.truename+"\")'><i class='ace-icon fa fa-users bigger-130'></i></a>&nbsp;&nbsp;"
			 }
		 }
		 function optGrant(uid,username,truename){
			 if(truename==null){
				 truename=username;
			 }
			 $.confirm("确认将"+truename+"设置为管理员？", function(){
		            $.ajax({
		                type:"POST",
		                url:"/user/admin/grant",
		                data:'uid='+uid,
		                cache:false,
		                async:false,
		                dataType:"json",
		                success: function(dataResult){
		                    alertMsg(dataResult.msg.msgText,dataResult.msg.msgStatus);
		                    optReloadGrid();
		                }
		            });
		        });
		 }
		 function optCancelGrant(uid,username,truename){
			 if(truename==null){
				 truename=username;
			 }
			 $.confirm("确认取消"+truename+"的管理员权限？", function(){
		            $.ajax({
		                type:"POST",
		                url:"/user/admin/grant_remove",
		                data:'uid='+uid,
		                cache:false,
		                async:false,
		                dataType:"json",
		                success: function(dataResult){
		                    alertMsg(dataResult.msg.msgText,dataResult.msg.msgStatus);
		                    optReloadGrid();
		                }
		            });
		        });
		 }
		 function optEdit(bid){
			 $.dialog("/book/admin/to_edit?bid="+bid,"修改","800px","500px");
		 }
		 function optQuery(method){
			 var postData = getWhere();
		        postData.type = method;
		        type=method;
		        jQuery("#grid-table-user").jqGrid('setGridParam',{page:1,postData:postData}).trigger("reloadGrid");
		 }
		 function query(){
		        optReloadGrid();
		 }
		</script>